#include "ResMgrPch.h"

#include "BinaryMemory.h"

BinaryMemory::BinaryMemory() :
	m_Memory(NULL),
	m_MemorySize(0)
{
}

BinaryMemory::~BinaryMemory()
{
	SAFE_DELETE_ARRAY(m_Memory);
}

void BinaryMemory::SetMemorySize( unsigned int memorySize )
{
	SAFE_DELETE_ARRAY(m_Memory);

	m_MemorySize = memorySize;
	m_Memory = new BYTE[m_MemorySize + 1];
	ZeroMemory( m_Memory, sizeof(BYTE) * ( m_MemorySize + 1 ) );
}

void BinaryMemory::SetMemory(void* memory, long FileSize)
{
	SAFE_DELETE_ARRAY(m_Memory);

	m_MemorySize = FileSize;
	m_Memory = new BYTE[m_MemorySize + 1];
	ZeroMemory(m_Memory, sizeof(BYTE) * ( m_MemorySize + 1 ) );
	memcpy_s(m_Memory, m_MemorySize, memory, m_MemorySize);
}